package com.nhim.core.dao;

import java.util.List;

public interface ICoreDAO<K, E> {

	/**
 Perform an initial save of a previously unsaved ElementDefinition entity. 
 All subsequent persist actions of this entity should use the #update() method.
 This operation must be performed within the a database transaction context for the entity's data to be permanently saved to the persistence store, i.e., database. 
 This method uses the {@link javax.persistence.EntityManager#persist(Object) EntityManager#persist} operation.
 	 <p>
 User-managed Spring transaction example:
 	 	 
 * <pre> 
 *   TransactionStatus txn = txManager.getTransaction(new DefaultTransactionDefinition());
 *   ElementDefinitionDAO.save(entity);
 *   txManager.commit(txn);
 * </pre>
 @see <a href = "http://www.nhimcms.com/documentation/quickstarts">Spring container-managed transaction examples</a>
   @param entity ElementDefinition entity to persist
  @throws RuntimeException when the operation fails
 */
	public void save(E entity);
	  /**
	 Delete a persistent ElementDefinition entity.
	  This operation must be performed 
	 within the a database transaction context for the entity's data to be
	 permanently deleted from the persistence store, i.e., database. 
	 This method uses the {@link javax.persistence.EntityManager#remove(Object) EntityManager#delete} operation.
	 	 <p>
	 User-managed Spring transaction example:
	 	 	 
	 * <pre> 
	 *   TransactionStatus txn = txManager.getTransaction(new DefaultTransactionDefinition());
	 *   ElementDefinitionDAO.delete(entity);
	 *   txManager.commit(txn);
	 *   entity = null;
	 * </pre>
	 @see <a href = "http://www.nhimcms.com/documentation/quickstarts">Spring container-managed transaction examples</a>
	   @param entity ElementDefinition entity to delete
	 @throws RuntimeException when the operation fails
	 */
	public void delete(E entity);
	/**
	 Persist a previously saved ElementDefinition entity and return it or a copy of it to the sender. 
	 A copy of the ElementDefinition entity parameter is returned when the JPA persistence mechanism has not previously been tracking the updated entity. 
	 This operation must be performed within the a database transaction context for the entity's data to be permanently saved to the persistence
	 store, i.e., database. This method uses the {@link javax.persistence.EntityManager#merge(Object) EntityManager#merge} operation.
	 	 <p>
	 User-managed Spring transaction example:
	 	 	 
	 * <pre> 
	 *   TransactionStatus txn = txManager.getTransaction(new DefaultTransactionDefinition());
	 *   entity = ElementDefinitionDAO.update(entity);
	 *   txManager.commit(txn);
	 * </pre>
	 @see <a href = "http://www.nhimcms.com/documentation/quickstarts">Spring container-managed transaction examples</a>
	   @param entity ElementDefinition entity to update
	 @return ElementDefinition the persisted ElementDefinition entity instance, may not be the same
	 @throws RuntimeException if the operation fails
	 */
	public E saveOrUpdate(E entity);
	public E findById(K id);
	public List<E> findAll();
	
}
